import { ApplicationRef, Component, ViewChild } from '@angular/core';

import { globalStore } from '@ds/ds-micro/dist';
import { getSingleStore } from '@ds/ds-micro-lib/dist';

function getReplaceUrl(url: string) {
  return url ? url.replace(/https:\/\/|http:\/\//, '').replace(/\/|\-|\:|\./g, '_') : '';
}

function getAppUrl() {
  return getReplaceUrl(getSingleStore('systemData').value.id) + '_' + getReplaceUrl(getSingleStore('systemData').value.host);
}

@Component({
  selector: '#customer app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.less'],
})
export class AppComponent {
  title = 'customer';
  i = 0;
  constructor(private appRef: ApplicationRef) {
    // console.log('=----========', globalStore('cacheRouter')[getAppUrl()]);
    // if (globalStore('cacheRouter')[getAppUrl()]) {
    //   this.appRef.attachView(globalStore('cacheRouter')[getAppUrl()].componentRef.hostView);

    //   this.appRef.bootstrap(globalStore('cacheRouter')[getAppUrl()].componentRef.componentType);
    // }

    setInterval(() => {
      console.log('=================================', this.i++);
    }, 5000);
  }
}
